import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_store_check_list(params) {
  const res = await request.post('/warehouse/store_check/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 门店列表 */
export async function get_store_list(params) {
  const res = await request.post('/tenant/store/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(new Error(res.data.msg));
}
/* 柜组列表 */
export async function get_store_groups_list(params) {
  const res = await request.post('/material/store_group/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(new Error(res.data.msg));
}
/* 门店用户 */
export async function get_store_user_list(params) {
  const res = await request.post('/user/store_user/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(new Error(res.data.msg));
}

/* 详情 */
export async function get_detail(params) {
  const res = await request.post('/warehouse/store_check/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 添加 */
export async function store_check_add(params) {
  const res = await request.post('/warehouse/store_check/add', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 点数 */
export async function store_check_check(params) {
  const res = await request.post('/warehouse/store_check/check', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 完成点数 */
export async function store_check_complete_check(params) {
  const res = await request.post(
    '/warehouse/store_check/complete_check',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消 */
export async function store_check_delete(params) {
  const res = await request.post('/warehouse/store_check/delete', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
